﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/master/CenterMain.Master"
    CodeBehind="UpdatePwd.aspx.cs" Inherits="com.huigo.B2B.Web.center.account.UpdatePwd" %>

<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        function SubmitCheck() {
            var pwd = /^[A-Za-z0-9_-]+$/;
            var before = $("#beforePwd").val();
            var newPwd = $("#newPwd").val();
            var newPwdAgain = $("#newPwdAgain").val();
            if ($.trim(before) == "") {
                $("#p_error").css("color", "red");
                $("#p_error").text("请输入当前登录密码");
                return false;
            }
            else {
                if (checkPwd() == true && checkPwdOK() == true) {
                    return true;
                }
                else {
                    return false
                }
            }
        }
        function checkPwd() {
            var pwd = /^[A-Za-z0-9_-]+$/;
            var newPwd = $("#newPwd").val();

            if ($.trim(newPwd) == "") {
                $("#pwd_error").css("color", "red");
                $("#pwd_error").text("请输入密码");
                return false;
            }
            else if (!RegExp(pwd).test(newPwd)) {
                $("#pwd_error").css("color", "red");
                $("#pwd_error").text("密码由英文、数字及“_”、“-”组成");
                return false;
            }
            else if (newPwd.length < 6 || newPwd.length > 20) {
                $("#pwd_error").css("color", "red");
                $("#pwd_error").text("密码长度只能在6-20位字符之间");
                return false;
            }
            else {
                return true;
            }
        }
        function checkPwdOK() {
            var newPwd = $("#newPwd").val();
            var newPwdAgain = $("#newPwdAgain").val();
            if ($.trim(newPwdAgain) == "") {
                $("#pwd2_error").css("color", "red");
                $("#pwd2_error").text("请输入密码");
                return false;
            }
            else if ($.trim(newPwd) != $.trim(newPwdAgain)) {
                $("#pwd2_error").css("color", "red");
                $("#pwd2_error").text("两次输入的密码不一致");
                return false;
            }
            else {
                return true;
            }
        }
        function err1() {
            $("#pwd_error").text("");
        };
        function err2() {
            $("#pwd2_error").text("");
        }
    </script>

    <h3 class="greybg">
        修改登录密码</h3>
    <form id="form1" runat="server" action="UpdatePwd.aspx" method="post">
    <table class="table table-striped responsive-utilities" style="min-width: 300px;
        width: 50%">
        <tr>
            <td style="width: 20%">
                当前登录密码
            </td>
            <td>
                <input type="password" id="beforePwd" name="beforePwd" />&nbsp;&nbsp;<span id="p_error">
            </td>
        </tr>
        <tr>
            <td>
                请输入新密码
            </td>
            <td>
                <input type="password" id="newPwd" name="newPwd" onblur="checkPwd();" onfocus="err1();" />&nbsp;&nbsp;<span
                    id="pwd_error"></span>
            </td>
        </tr>
        <tr>
            <td>
                请再输入一次
            </td>
            <td>
                <input type="password" id="newPwdAgain" name="newPwdAgain" onblur="checkPwdOK();"
                    onfocus="err2();" />&nbsp;&nbsp;<span id="pwd2_error"></span>
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;">
                <input type="hidden" id="isPost" name="isPost" value="true" /><input type="submit"
                    value="修改" id="submit" onclick="return SubmitCheck();" class="button btn-big btn-orange" />
            </td>
        </tr>
    </table>
    </form>
</asp:Content>
